package client.controller;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class CreateGroupDialogController {


    @FXML
    private TextField groupNameField;

    private OnGroupCreateListener listener;

    public void setOnGroupCreateListener(OnGroupCreateListener listener) {
        this.listener = listener;
    }

    @FXML
    private void onCancel() {
        Stage stage = (Stage) groupNameField.getScene().getWindow();
        stage.close();
    }

    @FXML
    private void onConfirm() {
        String groupName = groupNameField.getText().trim();
        if (!groupName.isEmpty() && listener != null) {

            listener.onCreate(groupName);
        }
        onCancel();
    }

    public interface OnGroupCreateListener {
        void onCreate(String groupName);
    }
}
